package net.mgsx.product.t2m.modisco.utility;

import org.eclipse.gmt.modisco.infra.query.core.exception.ModelQueryExecutionException;
import org.eclipse.gmt.modisco.infra.query.core.java.IJavaModelQuery;
import org.eclipse.gmt.modisco.java.AbstractMethodDeclaration;
import org.eclipse.gmt.modisco.java.ClassDeclaration;
import org.eclipse.gmt.modisco.java.emf.JavaFactory;
import org.junit.Test;

import net.mgsx.product.t2m.modisco.JavaModelQueryTestCase;

/**
 * IsUtilityClass JavaModelQuery TestCase
 * 
 * @author mgsx
 *
 */
public class IsUtilityClassTestCase extends JavaModelQueryTestCase<ClassDeclaration, Boolean>
{

	@Override
	protected IJavaModelQuery<ClassDeclaration, Boolean> instanciateQuery() {
		return new IsUtilityClass();
	}
	
	@Test
	public void testEvaluateNullModifier() throws ModelQueryExecutionException
	{
		final ClassDeclaration classDeclaration = JavaFactory.eINSTANCE.createClassDeclaration();
		final AbstractMethodDeclaration methodDeclaration = JavaFactory.eINSTANCE.createMethodDeclaration();
		methodDeclaration.setModifier(null);
		testEvaluateContext(classDeclaration, false);
	}
	
	@Test
	public void testEvaluateEmptyClass() throws ModelQueryExecutionException
	{
		final ClassDeclaration classDeclaration = JavaFactory.eINSTANCE.createClassDeclaration();
		testEvaluateContext(classDeclaration, false);
	}

	@Test
	public void testEvaluateClassWithStaticMethod() throws ModelQueryExecutionException
	{
		final ClassDeclaration classDeclaration = JavaFactory.eINSTANCE.createClassDeclaration();
		final AbstractMethodDeclaration methodDeclaration = JavaFactory.eINSTANCE.createMethodDeclaration();
		methodDeclaration.setModifier(JavaFactory.eINSTANCE.createModifier());
		methodDeclaration.getModifier().setStatic(true);
		classDeclaration.getBodyDeclarations().add(methodDeclaration);
		testEvaluateContext(classDeclaration, true);
	}
	
}
